﻿@model Model.AppUserList
@{
    ViewBag.Title = "WarrantyTime";
    Layout = "~/Views/Shared/_JQBaseLayOut.cshtml";
}
@using Model

@section JQscriptSection{
    <script type="text/javascript">
        $(document).ready(function () {
            InitGrid();

        });
        HandleDom.ClassTriggerClick("icon-add", function () {
            HandleDialog.OpenDialogByAdd('dlg', '添加商品可售期设置', function () {
                HandleData.ClearForm('location');
                HandleData.SetValueComboBox('txtStatus', "1");
                $('#txtPlusDays').val(0);
            });
        });

        HandleDom.ClassTriggerClick("icon-edit", function () {
            var row = HandleData.GetDataGridSelected("dg");
            edit(row);
        });

        function saveData(isClose) {
            HandleRequest.submitForm('location', '@Url.Action("SaveData", "WarrantyTime")', function (data) {
                eval('data=' + data);
                if (data.success == true) {
                    layer.alert('执行成功!', 9);
                    InitGrid();
                    HandleDialog.CloseDialog('dlg');
                } else {
                    layer.msg(data.msg, 1);
                }

            });


        }
        function InitGrid() {
            var startDate = $('#StartDate').datebox('getValue');
            var endDate = $('#EndDate').datebox('getValue');
            var status = $("#QuStatus").combobox('getValue');
            var ruleClass = $("#QuRuleclass").val();
            queryParams = {
                startDate: startDate,
                endDate: endDate,
                status: status,
                ruleClass:ruleClass
            }
            HandleData.InitDataGrid('dg', '/WarrantyTime/InitJsonResult', 'toolbar', queryParams, 'WTID', true,function(data){},
                                    function (rowIndex, rowData) {//双击
                                        edit(rowData);
            });
        }
        //编辑
        function edit(row) {
            HandleData.ClearForm('location');
            HandleDialog.OpenDialog(row, 'dlg', '编辑规则信息', function () {
                $('#txtBeginInt').val(row.BEGININT);
                $('#txtEndInt').val(row.ENDINT);
                $('#txtTimeProportion').val(row.TIMEPROPORTION);
                $('#txtPlusDays').val(row.PLUSDAYS);
                $('#txtRuleClass').val(row.RULECLASS);
                HandleData.SetValueComboBox('txtStatus', row.STATUS);
                $('#hiddenWTID').val(row.WTID);
                //$('#txtStatus').val(row.Status);  
            });
        }

    </script>
}

<body style="background-color: ButtonFace; font-size: 17px">
    <div class="easyui-panel" title="查询条件" style="height: 130px; padding: 5px; background: #fafafa; width: 1700px;">
        <form id="query" method="post">
            <table>
                <tr>
                    <td>创建时间:
                    </td>
                    <td>
                        <input class="easyui-datebox" id="StartDate" name="StartDate" style="width: 140px;" />
                    </td>
                    <td>~：
                    </td>
                    <td>
                        <input class="easyui-datebox" id="EndDate" name="EndDate" style="width: 140px;" validtype="compareDate['#StartDate']" />
                    </td>
                    <td>规则类别:</td>
                    <td>
                        <input  id="QuRuleclass" name="QuRuleclass" style="width:140px;" validtype="string['#QuRuleclass']" />
                    </td>
                    <td>状态:</td>
                    <td>
                        <select id="QuStatus" name="QuStatus" class="easyui-combobox"  style="width: 100px;" validtype="string['#QuStatus']">
                            <option value="">--全部--</option>
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </select>
                    </td>
                    <td>
                        <a id="btnSerach" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="InitGrid()">查询</a>
                    </td>
                </tr>
            </table>
        </form>

    </div>
    <div style="min-height: 720px; width: 1700px;">
        <table id="dg" title="数据信息" style="min-height: 600px;">
            <thead>
                <tr>
                    <th data-options="field:'BEGININT',width:30">开始天数</th>
                    <th data-options="field:'ENDINT',width:50">结束天数</th>
                    <th data-options="field:'TIMEPROPORTION',width:50">可售期比例</th>
                    <th data-options="field:'PLUSDAYS',width:50">另加天数</th>
                    <th data-options="field:'RULECLASS',width:50">规则类别</th>
                    <th data-options="field:'STATUS',width:50, align: 'center', sortable: true, formatter:function(value, rowData, rowIndex){ return FormatData.formatBool(value);}">状态</th>
                    <th data-options="field:'USERNAME',width:50">创建人</th>           
                    <th data-options="field:'CREATEDATE',width:130">创建时间</th>

                </tr>
            </thead>
        </table>
    </div>

    <div id="dlg" class="easyui-dialog" style="width: 550px; height: 200px; top: 300px; left: 400px; padding: 2px"
        data-options="closed:true,buttons:'#dlg-buttons',modal:true">
        <form id="location" method="post">
            <table>
                <tr>
                    <td>保质期开始天数:
                    </td>
                    <td>
                        <input id="hiddenWTID" name="hiddenWTID" type="hidden" />
                        <input id="txtBeginInt" name="txtBeginInt" class="easyui-validatebox" style="width: 154px" data-options="required:true" validtype="integer['#txtBeginInt']" />
                    </td>
                    <td>可售期比例:
                    </td>
                    <td>
                        <input id="txtTimeProportion" name="txtTimeProportion" class="easyui-validatebox" style="width: 100px" data-options="required:true" validtype="floatOrInt['#txtTimeProportion']" />
                    </td>
                </tr>
                <tr>
                    <td>保质期结束天数:
                    </td>
                    <td>
                        <input id="txtEndInt" name="txtEndInt" class="easyui-validatebox" style="width: 154px" data-options="required:true" validtype="integer['#txtEndInt']" />
                    </td>
                    <td>另加天数:
                    </td>
                    <td>
                        <input id="txtPlusDays" name="txtPlusDays" class="easyui-validatebox" style="width: 100px" data-options="required:true"  />
                    </td>
                </tr>
                <tr>
                    <td>规则类别:
                    </td>
                    <td>
                        <input id="txtRuleClass" name="txtRuleClass" class="easyui-validatebox" style="width: 154px" data-options="required:true"  />
                    </td>
                    <td>状态:
                    </td>
                    <td> 
                        <select id="txtStatus" name="txtStatus" class="easyui-combobox"  style="width: 100px;" validtype="string['#txtStatus']">
                            <option value="1">启用</option>
                            <option value="0">禁用</option>
                        </select>
                    </td>
                </tr>
                <tr>
                    <td>
                        <a id="btnSave" href="#" class="easyui-linkbutton" data-options="iconCls:'icon-save'" onclick="saveData(true)">保存</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    @Html.Partial("~/Views/Shared/_PartialToolbar.cshtml", new Toolbar
{
    GridName = "dg",
    GridType = "datagrid",
    ToolbarName = "toolbar",
    FunctionModule = new Dictionary<string, List<FunctionModule>>()
    {
        {"Function",new List<FunctionModule>()
            {
              new FunctionModule(){Name = "Add",IsEnable =true },
              new FunctionModule(){Name = "Edit",IsEnable =true },
              new FunctionModule(){Name = "Remove",IsEnable =false },
              new FunctionModule(){Name = "Reload",IsEnable =false },
              new FunctionModule(){Name = "Collapse",IsEnable =false },
              new FunctionModule(){Name = "Exporter",IsEnable =false },
              
            }
        }
    }
})

</body>



